/**
 * @filename:Const 2017年8月01日
 * @project 微面    边鹏  V1.0
 * Copyright(c) 2017 BianP Co. Ltd. 
 * All right reserved. 
 */
package com.lazy.develop.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.lazy.develop.generator.entity.User;
import com.lazy.develop.model.Record;
import com.lazy.develop.model.SwaggerTest;
import com.lazy.develop.service.UserService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.annotations.ApiIgnore;

/**	
 * 	@explain 控制层(用户)
 *  @author  BianP
 * 	@class   UserController.java
 */
@Api(description = "用户模块",value="用户。。" )
@RestController
@RequestMapping("/user")
public class UserController {

	Logger logger = Logger.getLogger(UserController.class);
	@Autowired
	public UserService userServiceImpl;
	
	/**
	 * @explain 获取用户
	 * @param   用户ID:id
	 * @return  User
	 * @author  BianP
	 */
	@ApiIgnore//使用该注解忽略这个API
	@RequestMapping(value="/getUserRolePage", method = RequestMethod.GET)
	public List<Record> getUserRolePage(HttpServletRequest request){
		Record record=new Record(request);
		//record.put("name", "name"); //和普通的map使用一样
		//String name=record.getString("name");
		//Integer id=record.getInteger("id");
		//Long id2=record.getLong("id");
		//Object obj=record.get("user"); //目前就写了这几个，大家可以根据自己的需求改哈
		List<Record> user = userServiceImpl.getUserRolePage(record);
		return user;
	}
	
	/**
	 * @explain 获取所有用户   <swagger POST请求>
	 * @param   对象参数：swaggerTest
	 * @return  List<User>
	 * @author  BianP
	 */
	@ApiOperation(value = "获取所有用户", notes = "查询所有用户")
	@RequestMapping(value="/getUserAll_POST", method = RequestMethod.POST)
	public List<User> getUserAll_POST(SwaggerTest swaggerTest){
		List<User> user = userServiceImpl.getUserAll();
		return user;
	}
	
	/**
	 * @explain 获取所有用户 <swagger get请求>
	 * @param   对象参数：swaggerTest
	 * @return  List<User>
	 * @author  BianP
	 */
	@ApiOperation(value = "获取所有用户", notes = "查询所有用户")
	@RequestMapping(value="/getUserAll_GET", method = RequestMethod.GET)
	public List<User> getUserAll_GET(SwaggerTest swaggerTest){
		List<User> user = userServiceImpl.getUserAll();
		return user;
	}
	
	
	/**
	 * @explain 获取所有用户 <swagger 链接参数与请求Body参数>
	 * @param   用户ID:id，对象参数：swaggerTest
	 * @return  List<User>
	 * @author  BianP
	 */
	@ApiOperation(value = "获取所有用户", notes = "查询所有用户")
	@ApiImplicitParams({
        @ApiImplicitParam(name = "ids", value = "用户ID", required = true, dataType = "Long",paramType = "path"),
        @ApiImplicitParam(name = "swaggerTest", value = "swagger测试参数对象", required = true, dataType = "SwaggerTest")
	})
	@RequestMapping(value="/getUserAll_POST/{ids}", method = RequestMethod.POST)
	public List<User> getUserAll_POST2(@PathVariable Long ids, @RequestBody SwaggerTest swaggerTest){
		List<User> user = userServiceImpl.getUserAll();
		return user;
	}
}
